#! /bin/bash
source /home/shell/location.sh
main(){
isNumber $2
isNumber=$?
case $1 in
	ls)
	firewall-cmd --list-ports
	;;
	add)
	getRunCode $isNumber add $2
	eval $CODE
	;;
	rm)
	getRunCode $isNumber remove $2
	eval $CODE
	;;
	*)
	echo -e "ls 列出所有开放的端口
add [port]
remove [port]"
	;;
esac
}
getRunCode(){
if [ ${1:-1} -eq 0 ]
then 
CODE="firewall-cmd --$2-port=$3/tcp --permanent && firewall-cmd --reload && echo $2 is success"
else CODE='echo port is error'
fi
}
main $*
